//
//  ZFBBottomListCell.m
//  01-ZFB
//
//  Created by My Mac on 2017/6/4.
//  Copyright © 2017年 MyMac. All rights reserved.
//

#import "ZFBHomeBottomListCell.h"
#import "ZFBHomeBottomList.h"
#import "ZFBHomeBottomView.h"
@interface ZFBHomeBottomListCell()

@property(nonatomic,strong) UIButton *button;

@end

@implementation ZFBHomeBottomListCell

-(void)awakeFromNib
{
    [super awakeFromNib];
    [self setUpUI];
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
    }
    return self;
}

//设置数据
-(void)setBottomList:(ZFBHomeBottomList *)bottomList
{
    _bottomList = bottomList;
    
    UIImage *image = [UIImage imageNamed:_bottomList.icon];
    
    NSAttributedString *attrStr = [NSAttributedString imageTextWithImage:image imageWH:25 title:_bottomList.name fontSize:14 titleColor:[UIColor colorWithRed:48/255.0 green:48/255.0 blue:48/255.0 alpha:1.0] spacing:10];
    
    [_button setAttributedTitle:attrStr forState:UIControlStateNormal];
}

-(void) setUpUI
{
    //设置背景颜色
    self.backgroundColor = [UIColor whiteColor];
    //添加和 cell bounds 一样大的按钮
    UIButton *button = [[UIButton alloc]initWithFrame:self.bounds];
    
    //设置button内容
    //1.设置多行文本
    button.titleLabel.numberOfLines = 0;
    //2.设置文本对齐方式
    button.titleLabel.textAlignment = NSTextAlignmentCenter;
    
    //添加响应事件
   // [button addTarget:self action:@selector(cellButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:button];
    
    //记录成员变量
    _button = button;
    
    [button setEnabled:NO];
    
    //设置约束
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.right.offset(0);
    }];
}

@end
